<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .box {
      position: absolute;
      left: 500px;

      width: 200px;
      height: 200px;
      background-color: #ff4af4;
    }
  </style>
</head>
<body>
<div class="box"></div>
<script>
  var box = document.querySelector('.box');

  function animate(obj, target) {
    obj.timer = setInterval(function () {
      obj.style.left = obj.offsetLeft + Math.ceil(target - obj.offsetLeft) / 10 + 'px';

      if (obj.offsetLeft == target) {
        clearInterval(obj.timer);
      }
    }, 10)
  }

  animate(box, 300);
</script>
</body>
</html>